<#include "/public/macro.html">
<style>
#contacts_city select,#contacts_cuscity select{
	width:100%;
}
</style>
<script src="/js/ztree/jquery.ztree.all.min.js"></script>
<link rel="stylesheet" href="/js/ztree/zTreeStyle/zTreeStyle.css">
<div class="ukefu-bt-text-content">
	<table class="layui-table" lay-skin="nob" style="margin: 0;">
		<tbody>
			<tr class="tdHasContorllor design-dropable-td">
				<!-- <td width="1%" nowrap="nowrap">关键词：</td>
				<td width="20%"><input type="text" name="q" value="${q!''}" style="height: 38px;line-height: 30px;margin-top: 10px;float:left;" placeholder="查询条件" autocomplete="off" class="layui-input"></td> -->
				<td width="1%" nowrap="nowrap">联系人名称：</td>
				<td width="20%"><input type="text" name="name" value="${name!''}" style="height: 38px;line-height: 30px;margin-top: 10px;float:left;" placeholder="联系人名称" autocomplete="off" class="layui-input"></td>
				
				<td width="1%" nowrap="nowrap">手机号：</td>
				<td width="20%">
					<input type="text" name="mobileno" value="${mobileno!''}" style="height: 38px;line-height: 30px;margin-top: 10px;float:left;" placeholder="手机号" autocomplete="off" class="layui-input">
				</td>
				
				<td width="1%" nowrap="nowrap">联系人状态：</td>
				<td width="20%">
					<@select "com.dic.contacts.business" "business" business!'' "lay-ignore" "width: 100%;"/>
				</td>
				<td width="1%" nowrap="nowrap">联系人说明：</td>
				<td width="20%">
				<input type="text" name="busmemo" value="${busmemo!''}" style="height: 38px;line-height: 30px;margin-top: 10px;float:left;" placeholder="业务需求说明" autocomplete="off" class="layui-input">
				</td>
			</tr>
			<tr class="tdHasContorllor design-dropable-td  td-search-hide">
				<td width="1%" nowrap="nowrap">获得时间：</td>
				<td width="20%">
					<input name="touchtimebegin" class="layui-input" placeholder="开始日期" value="${touchtimebegin!''}" data-datetype="laydate" autocomplete="off">
				</td>
				<td width="1%" nowrap="nowrap"  style="text-align: center;">～</td>
				<td width="20%">
					<input name="touchtimeend" class="layui-input" placeholder="结束日期" value="${touchtimeend!''}" data-datetype="laydate" autocomplete="off">
				</td>
				<td width="1%" nowrap="nowrap">通话时长：</td>
				<td width="20%">
					<input name="incallbegin" class="layui-input" placeholder="开始(秒)" value="${incallbegin!''}" type="number">
				</td>
				<td width="1%" nowrap="nowrap"  style="text-align: center;">～</td>
				<td width="20%">
					<input name="incallend" class="layui-input" placeholder="结束(秒)" value="${incallend!''}" type="number">
				</td>
			</tr>
			<tr class="tdHasContorllor design-dropable-td  td-search-hide">
				<td width="1%" nowrap="nowrap">更新时间：</td>
				<td width="20%">
					<input name="updatetimebegin" class="layui-input" placeholder="开始日期" value="${updatetimebegin!''}" data-datetype="laydate" autocomplete="off">
				</td>
				<td width="1%" nowrap="nowrap"  style="text-align: center;">～</td>
				<td width="20%">
					<input name="updatetimeend" class="layui-input" placeholder="结束日期" value="${updatetimeend!''}" data-datetype="laydate" autocomplete="off">
				</td>
				<td width="1%" nowrap="nowrap">备注：</td>
				<td width="20%">
					<input type="text" name="salesmemo" value="${salesmemo!''}" style="height: 38px;line-height: 30px;margin-top: 10px;float:left;" placeholder="备注" autocomplete="off" class="layui-input">
				</td>
				<td width="1%" nowrap="nowrap">当前处理人：</td>
				<td width="20%">
					<select id="owneruser" name="owneruser">
					<option value="">请选择</option>
					<#if userAuthorizeList?? && userAuthorizeList?size gt 0>
					<#list userAuthorizeList as user>
				  	<option value="${user.id!''}" <#if user.id == owneruser>selected="selected"</#if>>${user.username!}（${user.uname!}）</option>
				  	</#list>
				  	</#if>
					</select>
				</td>
				
			</tr>
			<tr class="tdHasContorllor design-dropable-td  td-search-hide">
				
				
				<td width="1%" nowrap="nowrap">业务状态：</td>
				<td width="20%">
					<div class="layui-input-inline" style="position: relative;width: 100%;">
					<input type="hidden" id="parentid" name="salestatus" value="<#if currsaleStatus??>${currsaleStatus.id}</#if>">
					<input type="text" name="parentname" id="parentname" required value="<#if currsaleStatus??>${currsaleStatus.name}<#elseif area??>${area.name!''}<#else>分类总揽</#if>" style="width: 100%;" autocomplete="off" readOnly="readonly" onClick="showMenu();"
						class="layui-input">
					<div id="menuContent" style="display:none; position: absolute;z-index:10000;width: 100%;height: 190px;" class="ukefu-ztree">
						<ul id="saleStatusTypeTree" class="ztree" style="width:95%;height: 180px;padding-right:1px;"></ul>
					</div>
					</div>
				</td>
				<td width="1%" nowrap="nowrap">微信号：</td>
				<td width="20%">
					<input type="text" name="weixin" value="${weixin!''}" style="height: 38px;line-height: 30px;margin-top: 10px;float:left;" placeholder="微信号" autocomplete="off" class="layui-input">
				</td>
				
				
				<#if !contactsItem??>
				<td width="1%" nowrap="nowrap">项目：</td>
				<td width="20%">
					 <select name="searchitemid">
			          <option value="">请选择项目</option>
			          <#if contactsItemList?? && contactsItemList?size gt 0>
						<#list contactsItemList as item1>
							<#if item1.parentid==''>
								<optgroup label="${item1.name!''}">
									<#list contactsItemList as item2>
										<#if item2.parentid==item1.id>
											<option value="${item2.id!''}">${item2.name!''}</option>
										</#if>
									</#list>
								</optgroup>
							</#if>
						</#list>
					  </#if>
			        </select>
				</td>
				</#if>
			</tr>
			<tr class="tdHasContorllor design-dropable-td  td-search-hide">
				<td width="1%" nowrap="nowrap">是否预约：</td>
				<td width="20%">
					<select name="reservation">
						<option value="">请选择是否预约</option>
						<option value="1" <#if reservation?? && reservation == "1">selected="selected"</#if>>是</option>
						<option value="0" <#if reservation?? && reservation == "0">selected="selected"</#if>>否</option>
					</select>
				</td>
				<td width="1%" nowrap="nowrap">预约方式：</td>
				<td width="20%">
					<@select "com.dic.summary.reservtype" "reservtype" reservtype!'' "lay-ignore" "width: 100%;"/>
				</td>
				<td width="1%" nowrap="nowrap">预约时间：</td>
				<td width="20%">
					<input name="optimebegin" class="layui-input" placeholder="开始日期" value="${optimebegin!''}" data-datetype="laydate" autocomplete="off">
				</td>
				<td width="1%" nowrap="nowrap"  style="text-align: center;">～</td>
				<td width="20%">
					<input name="optimeend" class="layui-input" placeholder="结束日期" value="${optimeend!''}" data-datetype="laydate" autocomplete="off">
				</td>
			</tr>
			<tr class="tdHasContorllor design-dropable-td  td-search-hide">
				<td width="1%" nowrap="nowrap">电子邮件：</td>
				<td width="20%">
					<input type="text" name="email" value="${email!''}" style="height: 38px;line-height: 30px;margin-top: 10px;float:left;" placeholder="电子邮件" autocomplete="off" class="layui-input">
				</td>
				<td width="1%" nowrap="nowrap">联系人地址：</td>
				<td width="20%">
				<input type="text" name="address" value="${address!''}" style="height: 38px;line-height: 30px;margin-top: 10px;float:left;" placeholder="联系人地址" autocomplete="off" class="layui-input">
				</td>
				<td width="1%" nowrap="nowrap">省份：</td>
				<td width="20%">
					<@select "com.dic.address.area" "province" province!'' "lay-ignore" "width: 100%;"/>
				</td>
				<td width="1%" nowrap="nowrap">城市：</td>
				<td width="20%" id="contacts_city">
					<#if city??>
					<@select city+".subdic" "city" city!'' "lay-ignore" "width: 100%;"/>
					<#else>
					<@select "com.dic.address.area.city" "city" city!'' "lay-ignore" "width: 100%;"/>
					</#if>
				</td>
			</tr>
			<tr class="tdHasContorllor design-dropable-td  td-search-hide">
				<td width="1%" nowrap="nowrap">类别：</td>
				<td width="20%">
					<select name="ctype">
						<option value="">联系人/客户</option>
						<option value="contacts" <#if ctype?? && ctype=="contacts">selected="selected"</#if>>联系人</option>
						<option value="customer" <#if ctype?? && ctype=="customer">selected="selected"</#if>>客户</option>
					</select>
				</td>
				<td width="1%" nowrap="nowrap">创建人：</td>
				<td width="20%">
					<select id="userid" name="creater" lay-ignore style="width: 100%;">
					<#list userList as user>
					<option value="">请选择</option>
				  	<option value="${userid!''}" <#if user.id == creater>selected="selected"</#if>>${user.username!}</option>
				  	</#list>
					</select>
				</td>
				<td width="1%" nowrap="nowrap">类型：</td>
				<td width="20%">
					<select name="ckinds">
						<option value="">请选择类型</option>
						<#list uKeFuDic['com.dic.contacts.ckind'] as macroSysDic>
						<option value="${macroSysDic.id!''}" <#if ckinds?? && macroSysDic?? && macroSysDic.id == ckinds>selected="selected"</#if>>${macroSysDic.name!''}</option>
						</#list>
					</select>
				</td>
				<td width="1%" nowrap="nowrap">性别：</td>
				<td width="20%">
					<select name="gender">
						<option value="">请选择性别</option>
						<option value="1" <#if gender?? && gender=="1">selected="selected"</#if>>男</option>
						<option value="0" <#if gender?? && gender=="0">selected="selected"</#if>>女</option>
						<option value="-1" <#if gender?? && gender=="-1">selected="selected"</#if>>未知</option>
					</select>
				</td>
			</tr>
			<tr class="tdHasContorllor design-dropable-td  td-search-hide">
				<td width="1%" nowrap="nowrap">客户名称：</td>
				<td width="20%"><input type="text" name="cusname" value="${cusname!''}" style="height: 38px;line-height: 30px;margin-top: 10px;float:left;" placeholder="客户名称" autocomplete="off" class="layui-input"></td>
				<td width="1%" nowrap="nowrap">客户-联系电话：</td>
				<td width="20%">
					<input type="text" name="cusphone" value="${cusphone!''}" style="height: 38px;line-height: 30px;margin-top: 10px;float:left;" placeholder="客户-联系电话" autocomplete="off" class="layui-input">
				</td>
				<td width="1%" nowrap="nowrap">客户-电子邮件：</td>
				<td width="20%"><input type="text" name="cusemail" value="${cusemail!''}" style="height: 38px;line-height: 30px;margin-top: 10px;float:left;" placeholder="客户-电子邮件" autocomplete="off" class="layui-input"></td>
				<td width="1%" nowrap="nowrap">客户地址：</td>
				<td width="20%">
				<input type="text" name="cusaddress" value="${cusaddress!''}" style="height: 38px;line-height: 30px;margin-top: 10px;float:left;" placeholder="联系人地址" autocomplete="off" class="layui-input">
				</td>
			</tr>
			<tr class="tdHasContorllor design-dropable-td td-search-hide">
				<td width="1%" nowrap="nowrap">客户-省份：</td>
				<td width="20%">
					<@select "com.dic.address.area" "cusprovince" cusprovince!'' "lay-ignore" "width: 100%;"/>
				</td>
				<td width="1%" nowrap="nowrap">客户-城市：</td>
				<td width="20%" id="contacts_cuscity">
					<#if city??>
					<@select city+".subdic" "cuscity" cuscity!'' "lay-ignore" "width: 100%;"/>
					<#else>
					<@select "com.dic.address.area.city" "cuscity" cuscity!'' "lay-ignore" "width: 100%;"/>
					</#if>
				</td>
				<td width="1%" nowrap="nowrap">客户类型：</td>
				<td width="20%">
					<@select "com.dic.contacts.entype" "ekind" ekind!'' "lay-ignore" "width: 100%;"/>
				</td>
				<td width="1%" nowrap="nowrap">客户级别：</td>
				<td width="20%">
					<@select "com.dic.contacts.elevel" "elevel" elevel!'' "lay-ignore" "width: 100%;"/>
				</td>
			</tr>
			<tr class="tdHasContorllor design-dropable-td td-search-hide">
				<td width="1%" nowrap="nowrap">客户来源：</td>
				<td width="20%">
					<@select "com.dic.contacts.esource" "esource" esource!'' "lay-ignore" "width: 100%;"/>
				</td>
				<td width="1%" nowrap="nowrap">客户-成熟度：</td>
				<td width="20%" id="contacts_city">
					<@select "com.dic.contacts.maturity" "maturity" maturity!'' "lay-ignore" "width: 100%;"/>
				</td>
				<td width="1%" nowrap="nowrap">客户行业：</td>
				<td width="20%">
					<@select "com.dic.contacts.industry" "industry" industry!'' "lay-ignore" "width: 100%;"/>
				</td>
				<td width="1%" nowrap="nowrap">客户状态：</td>
				<td width="20%">
					<@select "com.dic.contacts.validstatus" "cusvalidstatus" cusvalidstatus!'' "lay-ignore" "width: 100%;"/>
				</td>
			</tr>
			<!-- <tr class="tdHasContorllor design-dropable-td">
				<td width="1%" nowrap="nowrap">
					<button class="layui-btn layui-btn-sm" type="submit">
						<i class="layui-icon">&#xe615;</i> 
						查询
					</button>
				</td>
				<td width="1%" nowrap="nowrap" >
					<a href="javascript:void(0)" class="layui-btn layui-btn-sm" id="morebtn" data-btn="0" >
						<i class="layui-icon" id="moreicon">&#xe61a;</i> 
						展开更多
					</a>
				</td>
			</tr> -->
		</tbody>
	</table>
</div>
<script>
	$(document).ready(function(){
		
		$("#userid").select2({
			language:'zh-CN',
			placeholder:"请选择操作人",
			ajax:{
				url:"/res/users.html",
				dataType: 'json',
				delay: 250,
				processResults: function (data, params) {
					return {
						results: data
					};
				}    
			}
		});
		$('#province').change(function(){
			loadURL('/res/dic.html?id='+$(this).val()+"&name=city&attr=lay-ignore&style=width:100%;display:inline-block;" , '#contacts_city');
		})
		$('#cusprovince').change(function(){
			loadURL('/res/dic.html?id='+$(this).val()+"&name=city&attr=lay-ignore&style=width:100%;display:inline-block;" , '#contacts_cuscity');
		})
		$('#morebtn').click(function(){
			if($("#morebtn").attr("data-btn")=="0"){
				$("#morebtn").attr("data-btn","1")
				$("#moreicon").html("&#xe619;");
				$(".td-search-hide").show();
			}else{
				$("#morebtn").attr("data-btn","0")
				$("#moreicon").html("&#xe61a;");
				$(".td-search-hide").hide();
			}
		})
	});
</script>
<SCRIPT type="text/javascript">
	var setting = {
		data: {
			simpleData: {
				enable: true
			}
		},
		callback: {
			onClick: onClick,
			beforeClick: beforeClick
		}
	};
	
	function beforeClick(treeId, treeNode) {
		var zTree = $.fn.zTree.getZTreeObj("saleStatusTypeTree")
		nodes = zTree.getSelectedNodes();
		var allow = true , lastnode ;
		for (var i=0, l=nodes.length; i<l; i++) {
			lastnode = nodes[i].type ;
			if(nodes[i].organ && (nodes.length >= 1 && (event.ctrlKey || event.shiftKey))){
				allow = false ; break ;
			}
		}
		if(lastnode != treeNode.type && (event.ctrlKey || event.shiftKey)){
			allow = false ;
		}
		
		if (allow == false) {
			top.layer.alert("组织机构不能点选多个上级机构，也不能同时选择地区和机构", {icon: 3});
			return false;
		} else {
			return true;
			
		}
	}
	
	function onClick(e, treeId, treeNode) {
		var zTree = $.fn.zTree.getZTreeObj("saleStatusTypeTree"),
		nodes = zTree.getSelectedNodes(),
		v = "" , value = "";
		nodes.sort(function compare(a,b){return a.id-b.id;});
		for (var i=0, l=nodes.length; i<l; i++) {
			v += nodes[i].name + ",";
			if(value != ""){
				value = value + "," ;
			}
			value = nodes[i].id ;
		}
		if (v.length > 0 ) v = v.substring(0, v.length-1);
		if(treeNode.type == "saleStatus"){
			$("#parentname").attr("value", v);
			$("#parentid").attr("value", value);
		}
		if (!event.ctrlKey && !event.shiftKey && treeNode.type == "saleStatus") {
			hideMenu() ;
		}
		/* loadURL("/apps/contacts/reservation/salestatuslist.html?id="+treeNode.id,"#salestatus"); */
	}


	var zNodes =[
	    { id:'0', pId:'00', name:"分类总揽", open:true , saleStatusTypeParent : true, type : "saleStatusTypeParent"}
	    <#if saleStatusTypeList??>
	    <#list saleStatusTypeList as saleStatus>
	    <#if saleStatus.activityid?? && statusCode?? &&  saleStatus.activityid == statusCode>
	    ,{ id:'${saleStatus.id!''}', pId:'${saleStatus.parentid!'0'}', name:"${saleStatus.name!''}", open:false }
	    </#if>
	    </#list>
	    </#if>
	    <#if saleStatusList?? >
	    <#list saleStatusList as saleStatus>
	    ,{ id:'${saleStatus.id!''}', pId:'${saleStatus.cate!'0'}', name:"${saleStatus.name!''}" ,  icon:"/images/dept.png", type : "saleStatus", saleStatus : true}
	    </#list>
	    </#if>
	];
	$(document).ready(function(){
		var ztree = $.fn.zTree.init($("#saleStatusTypeTree"), setting, zNodes);
		<#if currsaleStatus??>
		var node = ztree.getNodeByParam('id', '${currsaleStatus.id!''}');//获取id为1的点
		ztree.selectNode(node);//选择点  
		</#if>
		/* <#if area??>
		var node = ztree.getNodeByParam('id', '${area.id!''}');//获取id为1的点
		ztree.selectNode(node);//选择点  
		</#if> */
	});
	function showMenu() {
		$("#menuContent").css({left:"0px", top:"38px"}).show();

		$("body").bind("mousedown", onBodyDown);
	}
	function hideMenu() {
		$("#menuContent").hide();
		$("body").unbind("mousedown", onBodyDown);
	}
	function onBodyDown(event) {
		if (!(event.target.id == "menuBtn" || event.target.id == "menuContent" || $(event.target).parents("#menuContent").length>0)) {
			hideMenu();
		}
	}

</SCRIPT>